﻿using System;
using Microsoft.Samples.Kinect.WpfViewers;

namespace SVU.Managers
{
    public static class FeedbackManager
    {
        public static void AddFeedback(string feedback)
        {
            KinectDiagnosticViewer.Instance.Dispatcher.Invoke(
                new Action(
                    () => { 
                        KinectDiagnosticViewer.Instance.lstConsole.Items.Add(feedback);
                        KinectDiagnosticViewer.Instance.lstConsole.ScrollIntoView(KinectDiagnosticViewer.Instance.lstConsole.Items[KinectDiagnosticViewer.Instance.lstConsole.Items.Count - 1]);
                    }
                    ));
        }

        public static void UpdateStatus()
        {
            string status = SvuConstants.State.ToString().Replace("Mode", "").Replace("_", " ");

            KinectDiagnosticViewer.Instance.Dispatcher.Invoke(
                new Action(
                    () =>
                        {
                            KinectDiagnosticViewer.Instance.txtSvuStatus.Text = "Status: " + status;
                            if (status != "Authentication Success")
                                AddFeedback(KinectDiagnosticViewer.Instance.txtSvuStatus.Text);
                        }
                    ));
        }

        public static void UpdatePerson(string person)
        {
            KinectDiagnosticViewer.Instance.Dispatcher.Invoke(
                new Action(
                    () => KinectDiagnosticViewer.Instance.txtSvuPerson.Text = "Person: " + person
                    ));
        }

        public static void UpdatePersonMeasurement(string personMeasurement)
        {
            KinectDiagnosticViewer.Instance.Dispatcher.Invoke(
                new Action(
                    ()=> { KinectDiagnosticViewer.Instance.txtSvuPersonMeasurement.Text = personMeasurement; }
                    ));
        }
    }
}